/***************************************************************************
 * Copyright 2012-2013 TXT e-solutions SpA
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * This work was performed within the IoT_at_Work Project
 * and partially funded by the European Commission's
 * 7th Framework Programme under the contract ICT-257367.
 *
 * Authors:
 *      Salvatore Piccione (TXT e-solutions SpA)
 *
 * Contributors:
 *        Domenico Rotondi (TXT e-solutions SpA)
 **************************************************************************/
package it.txt.ens.client.subscriber.impl.osgi;

import it.txt.ens.client.core.factory.ENSBrokerConnectionParametersFactory;
import it.txt.ens.client.impl.osgi.BasicENSClientMSF;
import it.txt.ens.client.subscriber.ENSSubscriber;
import it.txt.ens.client.subscriber.impl.BasicENSEventFactory;
import it.txt.ens.client.subscriber.impl.BasicENSSubscriber.BasicENSSubscriberFactory;
import it.txt.ens.core.ENSAuthzServiceConnectionParameters;
import it.txt.ens.core.ENSResource;
import it.txt.ens.core.KeystoreParameters;
import it.txt.ens.core.X509CertificateRetrievalParameters;
import it.txt.ens.schema.request.factory.ENSAuthorisationRequestFactory;
import it.txt.ens.schema.response.factory.ENSAuthorisationResponseFactory;

import java.io.File;
import java.util.Date;

import org.osgi.framework.BundleContext;

/**
 * @author Salvatore Piccione (TXT e-solutions SpA - salvatore.piccione AT txtgroup.com)
 * @author Domenico Rotondi (TXT e-solutions SpA - domenico.rotondi AT txtgroup.com)
 *
 */
public class BasicENSSubscriberMSF extends BasicENSClientMSF<ENSSubscriber>{
    
    public static final String IMPLEMENTATION_ID = "default";
    
//    private static final Logger LOGGER = Logger.getLogger(BasicENSSubscriberMSF.class.getName());
    
    public BasicENSSubscriberMSF (BundleContext context) {
        super(context, ENSSubscriber.class);
    }
    
    /* (non-Javadoc)
     * @see org.osgi.service.cm.ManagedServiceFactory#getName()
     */
    @Override
    public String getName() {
        return this.getClass().getName();
    }

    /* (non-Javadoc)
     * @see it.txt.ens.client.impl.osgi.BasicENSClientMSF#createClient(java.lang.String, it.txt.ens.core.ENSResource, it.txt.ens.core.ENSAuthzServiceConnectionParameters, it.txt.ens.core.KeystoreParameters, it.txt.ens.core.X509CertificateRetrievalParameters, java.io.File, it.txt.ens.client.core.factory.ENSEventFactory, it.txt.ens.client.core.factory.ENSBrokerConnectionParametersFactory, it.txt.ens.schema.request.factory.ENSAuthorisationRequestFactory, it.txt.ens.schema.response.factory.ENSAuthorisationResponseFactory)
     */
    @Override
    protected ENSSubscriber createClient(
            String pid,
            String subjectID,
            ENSResource targetResource,
            ENSAuthzServiceConnectionParameters accessRequestBrokerConnParams,
            KeystoreParameters keystoreParams,
            X509CertificateRetrievalParameters certParams,
            File capabilityDirectory,
            Date preferredSessionExpiration,
            ENSBrokerConnectionParametersFactory ensBrokerConnectionParametersFactory, 
            ENSAuthorisationRequestFactory requestFactory, ENSAuthorisationResponseFactory responseFactory) {
        
        return new BasicENSSubscriberFactory().create(
            subjectID, targetResource, 
            preferredSessionExpiration,
            accessRequestBrokerConnParams, keystoreParams, certParams, capabilityDirectory, requestFactory,
            responseFactory, ensBrokerConnectionParametersFactory, new BasicENSEventFactory());
    }
}
